home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr26
/
memspd.zip
/
MEMSPDA.A
< prev
Wrap
Text File
|
1993-03-31
|
10KB
|
740 lines
;*M* MEMSPDA - Memory speed measurer subroutines
;
ise 386
;
;
;
; Includes
;
include hka7kbat.aim
include hb7bios.aim
include hma7mthb.aim
;
;
;
; Defs
;
entry ADDRH
entry IORDB
entry IORDW
entry LOAD
entry LOADEM
entry LOADH
entry MEML
entry MEMH
entry STORB
entry STORW
entry interval
;
;
;
; Refs
;
extrn USR
;
;
;
; Macros
;
MACRO
setoff
xor si,si
xor di,di
mov cx,CNT
ENDM
;
;
;
code: rel
;
data: rel
;
CNT equ 800H ; must be at least 200H
;
stack ds 100H
stkend equ $
clkval dw 0
clkval1 dw 0
interval dw 0,0
intervalb dw 0
myds dw 0
align 8
gdtr ds 8
gdt ds 6*8
align 4
bfr ds CNT
;
;
using
;
ds 256
start equ $
;
nop
mov ax,cs
mov ds,ax
mov ss,ax
mov sp,stkend
mov es,ax
cld
;
call USR
;
mov ah,4CH
int 21H
;
;
;
ADDRH equ $
;
call .kbwait ; wait for OK to write
mov al,0D1h ; enable access to mem above the A20 line
out (64h),al
call .kbwait
mov al,0DFh
out (60h),al
;
mov bx,1
push ds
push es
xor ax,ax
mov ds,ax
dec ax
mov es,ax
xor si,si
mov di,10H
mov cx,800H
cli
repz
cmps
pop es
pop ds
je .$10
dec bx
.$10: ret
;
.kbwait equ $
in al,(64H) ; spin until data has been accepted
test al,02H
jnz .kbwait
ret
;
;
;
P$SEG value 8
P$FLG value 6
P$SIZ value 4
;
LOAD equ $
push bp
mov bp,sp
;
push es
cli
mov es,(bp+P$SEG)
call disrupt
xor si,si
mov cx,1000H
cmpw (bp+P$FLG),0
jne .$10
cmpw (bp+P$SIZ),1
je .$07
ja .$08
rep
lods es:
jmpr .$10
.$07: rep
lodsw es:
jmpr .$10
.$08: rep
lodsw,eo es:
;
.$10: xor si,si
mov cx,1000H
call inittime
cmpw (bp+P$SIZ),1
je .$12
ja .$14
rep
lods es:
jmpr .$16
.$12: rep
lodsw es:
jmpr .$16
.$14: rep
lodsw,eo es:
.$16: call calctime
sti
;
pop es
;
mov ax,(interval)
cmpw (bp+P$SIZ),0
jne .$19
shr ax
mov (intervalb),ax ; save byte time / 2
jmpr .$21
.$19: cmp ax,(intervalb)
ja .$21
incw (interval+2)
;
.$21: mov ax,84
mulw (interval) ; convert clock tics to usec
cmpw (interval+2),0
je .$23
add dx,84/2
.$23: mov cx,1000H
div cx ; get usec per xaction * 100
;
mov bx,ax
pop bp
ret 6
;
;
;
P$SEG value 8
P$FLG value 6
P$SIZ value 4
;
LOADH equ $
push bp
mov bp,sp
;
push es
cli
;
mov ax,0FFFFH
mov es,ax
call disrupt
mov cx,1000H
mov si,100H
cmpw (bp+P$FLG),0
jne .$10
cmpw (bp+P$SIZ),1
je .$07
ja .$08
rep
lods es:
jmpr .$10
.$07: rep
lodsw es:
jmpr .$10
.$08: rep
lodsw,eo es:
;
.$10:
mov cx,1000H
mov si,100H
call inittime
cmpw (bp+P$SIZ),1
je .$12
ja .$14
rep
lods es:
jmpr .$16
.$12: rep
lodsw es:
jmpr .$16
.$14: rep
lodsw,eo es:
.$16: call calctime
sti
;
pop es
;
mov ax,(interval)
cmpw (bp+P$SIZ),0
jne .$19
shr ax
mov (intervalb),ax ; save byte time / 2
jmpr .$21
.$19: cmp ax,(intervalb)
ja .$21
incw (interval+2)
;
.$21: mov ax,84
mulw (interval) ; convert clock tics to usec
cmpw (interval+2),0
je .$23
add dx,84/2
.$23: mov cx,1000H
div cx ; get usec per xaction * 100
;
pop bp
mov bx,ax
ret 6
;
;
;
P$BASE value 8
P$FLG value 6
P$SIZ value 4
;
LOADEM equ $
push bp
mov bp,sp
;
push es
mov eax,(bp+P$BASE) ; init extra seg selector with this base
call setgdt
call goprot ; go into protected mode, disable
mov ax,3*8 ; selector of extra segment
mov es,ax
call disruptem
xor si,si
mov cx,1000H
cmpw (bp+P$FLG),0
jne .$10
cmpw (bp+P$SIZ),1
je .$07
ja .$08
rep
lods es:
jmpr .$10
.$07: rep
lodsw es:
jmpr .$10
.$08: rep
lodsw,eo es:
;
.$10: xor si,si
mov cx,1000H
call inittime
cmpw (bp+P$SIZ),1
je .$12
ja .$14
rep
lods es:
jmpr .$16
.$12: rep
lodsw es:
jmpr .$16
.$14: rep
lodsw,eo es:
.$16: call calctime
call goreal ; go back into real mode, enable
;
pop es
;
mov ax,(interval)
cmpw (bp+P$SIZ),0
jne .$19
shr ax
mov (intervalb),ax ; save byte time / 2
jmpr .$21
.$19: cmp ax,(intervalb)
ja .$21
incw (interval+2)
;
.$21: mov ax,84
mulw (interval) ; convert clock tics to usec
cmpw (interval+2),0
je .$23
add dx,84/2
.$23: mov cx,1000H
div cx ; get usec per xaction * 100
;
mov bx,ax
pop bp
ret 8
;
;
;
MEMH equ $
;
mov ah,88H
int 15H
mov bx,ax
test bh,80H
je .$20
xor bx,bx ; none
.$20: or bx,bx
je .$30 ; none
;
cli
mov al,0D1h ; enable access to mem above the A20 line
out (64h),al
jmpr $+2
.wrbusy in al,(HKA9Rstat) ; spin until data has been accepted
test al,HKA9Srdry
jnz .wrbusy
mov al,HKA9OPa20
out (HKA9Rdata),al
sti
;
.$30: ret ; return extended mem size in K
;
;
;
MEML equ $
;
int HB9Imsiz ; get mem size in K excluding BIOS ext mem
add ax,63
and ax,-64 ; round up
mov bx,ax
ret
;
;
;
STORB equ $
;
push ds
pop es
cli
mov di,bfr
mov cx,CNT
call inittime
rep
stos
call calctime
sti
;
mov ax,84
mulw (interval) ; convert clock tics to usec
mov cx,CNT
div cx ; get usec per xaction * 100
;
mov bx,ax
ret
;
;
;
STORW equ $
;
push ds
pop es
cli
mov di,bfr
mov cx,CNT/2
call inittime
rep
stosw
call calctime
sti
;
mov ax,84
mulw (interval) ; convert clock tics to usec
mov cx,CNT/2
div cx ; get usec per xaction * 100
;
mov bx,ax
ret
;
;
;
P$IOA value 4
;
IORDB equ $
push bp
mov bp,sp
;
push ds
pop es
cli
mov di,bfr
mov cx,CNT
mov dx,(bp+P$IOA)
call inittime
rep
ins
call calctime
sti
;
mov ax,84
mulw (interval) ; convert clock tics to usec
mov cx,CNT
div cx ; get usec per xaction * 100
;
mov bx,ax
pop bp
ret 2
;
;
;
P$IOA value 4
;
IORDW equ $
push bp
mov bp,sp
;
push ds
pop es
cli
mov dx,(bp+P$IOA)
cmp dx,1F0H
je .$08
cmp dx,170H
jne .$10
.$08: call setdisk
.$10:
mov di,bfr
if CNT.lt.200H
error 'CNT is too small'
endif
mov cx,200H/2
call inittime
rep
insw
call calctime
sti
;
mov ax,84
mulw (interval) ; convert clock tics to usec
mov cx,200H/2
div cx ; get usec per xaction * 100
;
mov bx,ax
pop bp
ret 2
;
;
setdisk equ $
;
push dx
add dx,2
mov al,1
out (dx),al ; # sectors
jmpr $+2
inc dx
out (dx),al ; sector #
jmpr $+2
inc dx
xor al,al
out (dx),al ; cyl low
jmpr $+2
inc dx
out (dx),al ; cyl high
jmpr $+2
inc dx
mov al,0A0H
out (dx),al ; drive select, head select
jmpr $+2
inc dx
mov al,20H
out (dx),al ; read command
mov cx,200H
loop $
.$15: in al,(dx)
test al,80H
je .$18
loop .$15
.$18: test al,8
jne .$20 ; wait for DRQ
loop .$15
.$20: mov cx,100H
loop $
pop dx
ret
;
;
;
;*D* NAME: inittime
;*D* CALL: call inittime
;*D* DESCRIPTION: Disables, reads the current clock value, and saves it
;*D* in CLKVAL.
;
inittime equ $
;
call gettime
mov (clkval),ax
ret
;
;
;
;*D* NAME: calctime
;*D* CALL: call calctime
;*D* DESCRIPTION: Reads the current clock value, subtracts it from the
;*D* value in CLKVAL, enables and returns the result.
;*D* If sign bit is set, the result is not meaningful.
;
calctime equ $
call gettime
mov (clkval1),ax
neg ax
add ax,(clkval)
shr ax
mov (interval),ax
movw (interval+2),0
ret
;
;
;
;*D* NAME: gettime
;*D* CALL: call gettime
;*D* DESCRIPTION: Gets the current clock value.
;
gettime equ $
;
mov al,HMA9TClat+HMA9TCc0
out (HMA9TBpri+HMA9TRctl),al
jmpr $+2
in al,(HMA9TBpri+HMA9TR0)
mov ah,al
jmpr $+2
in al,(HMA9TBpri+HMA9TR0)
xchg al,ah
ret
;
;
;
;*D* NAME: disrupt
;*D* CALL: call disrupt
;*D* DESCRIPTION: If the segment being tested is >= 2000H, loads 64K from
;*D* 1000H and then 0000H, else loads 64K from 3000H and then
;*D* 2000H. The intent is to get all data from the segment
;*D* being tested out of the cache.
;
disrupt equ $
;
std
push es
mov ax,es
cmp ax,2000H
jae .$05
mov bx,3000H
jmpr .$10
.$05: mov bx,1000H
.$10: mov es,bx
mov si,0FFFEH
mov cx,8000H
rep
lodsw es:
sub bx,1000H
test bh,10H
je .$10
pop es
cld
ret
;
;
;
;*D* NAME: disruptem
;*D* CALL: call disruptem
;*D* DESCRIPTION: Loads 128K starting at real mem zero in order to disrupt
;*D* the cache.
;
disruptem equ $
;
push es
mov ax,4*8 ; GDT 4
mov es,ax
xor si,si
mov cx,8000H
rep
lodsw es:
mov ax,5*8 ; GDT 5
mov es,ax
xor si,si
mov cx,8000H
rep
lodsw es:
pop es
ret
;
;
;
goprot equ $
;
mov (myds),ds
mov (gorcs),cs
cli
push eax
lgdt (gdtr)
mov eax,cr0
or al,1
mov cr0,eax
jmpr $+2
mov ax,2*8 ; data selector
mov ss,ax
mov ds,ax
mov es,ax
jmpl .gop10,1*8
.gop10: pop eax
ret
;
;
;
goreal equ $
;
push eax
push cx
mov cx,(myds)
mov eax,cr0
and al,.not.1
mov cr0,eax
jmpl gor10,0
gorcs equ $-2
gor10: mov ds,cx
mov es,cx
mov ss,cx
pop cx
pop eax
sti
ret
;
;
;
setgdt equ $
;
push eax
push ebx
push ecx
;
push eax
;
movw (gdtr),(6*8)-1 ; GDT limit
xor ebx,ebx
mov bx,ds
shl ebx,4
xor ecx,ecx
mov cx,gdt
add ebx,ecx
mov (gdtr+2),ebx ; GDT base
;
mov di,gdt+8 ; GDT 1: Code descriptor
movw (di),0FFFFH
mov cx,cs
shl cx,4
mov (di+2),cx ; low of base
mov cx,cs
shr cx,12
mov (di+4),cl ; middle of base
mov (di+5),9BH ; present, data/code, executable, code, used
;
mov di,gdt+16 ; GDT 2: Data descriptor
movw (di),0FFFFH
mov cx,ds
shl cx,4
mov (di+2),cx ; low of base
mov cx,ds
shr cx,12
mov (di+4),cl ; middle of base
mov (di+5),93H ; present, data/code, data, used
;
mov di,gdt+24 ; GDT 3: Extra descriptor
movw (di),0FFFFH
pop eax
mov (di+2),ax ; low of base
shr eax,16
mov (di+4),al ; middle of base
mov (di+5),93H ; present, data/code, data, used
;
mov di,gdt+32 ; GDT 4: Low 64K descriptor
movw (di),0FFFFH
movw (di+2),0 ; low of base
mov (di+4),0 ; middle of base
mov (di+5),93H ; present, data/code, data, used
;
mov di,gdt+40 ; GDT 5: Next 64K descriptor
movw (di),0FFFFH
movw (di+2),0 ; low of base
mov (di+4),1 ; middle of base
mov (di+5),93H ; present, data/code, data, used
;
pop ecx
pop ebx
pop eax
ret
;
end start